package com.timguan.render.dao.persistence.cms;

import com.timguan.render.dao.domain.cms.CmsTopicDOExample;
import org.apache.ibatis.jdbc.SQL;

/**
 * mbg sql扩展
 * Created by guankaiqiang on 2015/3/2.
 */
public class CmsTopicDOSqlProdviderExt extends CmsTopicDOSqlProvider {
    public String selectActivityIdsByExample(CmsTopicDOExample example) {
        SQL sql = new SQL();
        if (example != null && example.isDistinct()) {
            sql.SELECT_DISTINCT("id");
        } else {
            sql.SELECT("id");
        }
        sql.FROM("cms_topic");
        applyWhere(sql, example, false);

        if (example != null && example.getOrderByClause() != null) {
            sql.ORDER_BY(example.getOrderByClause());
        }

        if (example.getOffset() > -1 && example.getRows() > 0) {
            return sql.toString() + " limit " + example.getOffset() + "," + example.getRows();
        }
        return sql.toString();
    }
}
